home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / What's New? / Development Kits / Mac OS / USB DDK 1.4.6f4 / Examples / USBEnetSample / USBEnetDriver.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-23  |  4.4 KB  |  178 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        USBEnetDriver.h
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 2000 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                xxx put dri here xxx
  13.  
  14.         Other Contact:        xxx put other contact here xxx
  15.  
  16.         Technology:            xxx put technology here xxx
  17.  
  18. */
  19.  
  20. #ifndef    _USBENETDRIVER_
  21. #define    _USBENETDRIVER_
  22.  
  23. typedef struct
  24. {
  25.     UInt8     bFunctionLength;
  26.     UInt8     bDescriptorType;
  27.     UInt8     bDescriptorSubtype;
  28.     UInt8     iMACAddress;
  29.     UInt8     bmEthernetStatistics[4];
  30.     UInt8     wMaxSegmentSize[2];
  31.     UInt8     wNumberMCFilters[2];
  32.     UInt8     bNumberPowerFilters;
  33. } FunctionalDescriptor;
  34.  
  35. typedef struct
  36. {
  37.     USBPB                         pb;
  38.     unsigned char                 *errorString;
  39.     UInt16                         interfacenum;
  40.     USBDeviceRef                 deviceRef;
  41.     USBInterfaceRef                interfaceRef;
  42.     USBPipeRef                     interrupt;
  43.     USBPipeRef                     bulkIn;
  44.     USBPipeRef                     bulkOut;
  45.     USBDeviceDescriptorPtr        deviceDescriptor;
  46.     FunctionalDescriptor        FuncDesc;
  47.     UInt8                         bMACAddress[6];
  48.     UInt8                         onError;
  49.     UInt8                         retries;
  50. } EnetPB;
  51.  
  52. typedef UInt8                EnetAddress[6];
  53. typedef UInt8                 *EnetAddressPtr;
  54.  
  55. typedef struct EnetAddressListElement    EnetAddressListElement;
  56. typedef EnetAddressListElement *EnetAddressListPtr;
  57.  
  58. struct EnetAddressListElement
  59. {
  60.     EnetAddressListPtr            next;
  61.     EnetAddress                    address;
  62.     UInt8                        _pad[2];
  63. };
  64.  
  65. enum{
  66.     kReset                     = 0,
  67.     kCommConfig             = 1,
  68.     kSetConfig                 = 2,
  69.     kGetCommInterface         = 3,
  70.     kSetCommInterface        = 4,
  71.     kConfigureCommInterface = 5,
  72.     kGetInterruptEndpoint     = 6,
  73.     kStartGetDescriptors    = 7,
  74.     kGetDescriptors            = 8,
  75.     kSetDataConfig            = 9,
  76.     kDataConfig             = 10,
  77.     kGetDataInterface         = 11,
  78.     kConfigureDataInterface = 12,
  79.     kGetBulkOutEndpoint     = 13,
  80.     kGetBulkInEndpoint         = 14,
  81.     kConfigDone             = 15,
  82.     kInstallDrvr            = 16,
  83.     
  84.     kEndpointStall             = 1,
  85.     kStallDone                 = 2,
  86.     kAvailableStatus         = 'okok'
  87. };
  88.     
  89. //    Requests
  90. enum{
  91.     kSend_Encapsulated_Command                        = 0,
  92.     kGet_Encapsulated_Response                        = 1,
  93.     kSet_Ethernet_Multicast_Filter                    = 0x40,
  94.     kSet_Ethernet_Power_Management_Packet_Filter    = 0x41,
  95.     kGet_Ethernet_Power_Management_Packet_Filter    = 0x42,
  96.     kSet_Ethernet_Packet_Filter                        = 0x43,
  97.     kGet_Ethernet_Statistics                        = 0x44,
  98.     kGet_AUX_Inputs                                    = 4,
  99.     kSet_AUX_Outputs                                = 5,
  100.     kSet_Temp_MAC                                    = 6,
  101.     kGet_Temp_MAC                                    = 7,
  102.     kSet_URB_Size                                    = 8,
  103.     kSet_SOFS_To_Wait                                = 9,
  104.     kSet_Even_Packets                                = 10,
  105.     kScan                                            = 0xFF
  106. };
  107.     
  108. //Notifications
  109. enum{
  110.     kNetwork_Connection                = 0,
  111.     kResponse_Available                = 1,
  112.     kConnection_Speed_Change        = 0x2A
  113. };
  114.     
  115. enum{
  116.     kInterrupt            = 100,
  117.     kReplaceInterrupt    = 2,
  118.     kFixupInterrupt        = 3,
  119.     kForceInterrupt        = 6,
  120.     
  121.     kURB_Size            = 4096,
  122.     kSOFS                = 1,
  123.     kType_Multicast        = 0x0010,
  124.     kType_Broadcast        = 0x0008,
  125.     kType_Directed        = 0x0004,
  126.     kType_All_Multicast    = 0x0002,
  127.     kType_Promiscuous    = 0x0001
  128. };
  129.  
  130. enum{
  131.     CS_Interface                    = 0x24,
  132.     Ethernet_Functional_Descriptor    = 0x0f
  133. };
  134.  
  135. /********************************************************************************************/
  136. //
  137. //    Prototypes
  138. //
  139. /********************************************************************************************/
  140.  
  141. void        CheckUSBVersion(void);
  142. void         USBStatus(UInt32 level, USBDeviceRef ref, void *pointer, UInt32 value);
  143. static         Boolean immediateError(OSStatus err);
  144. static void ConfigurationHandler(USBPB *pb);
  145. static void ResetInterruptPB(USBPB *pb);
  146. static void interruptCompletion(USBPB *pb);
  147. static void StartStatusMonitor(USBPipeRef interruptPipe);
  148. static void syncCompletion(USBPB *pb);
  149. UInt32         USBReadData(UInt8 *buf, UInt32 size);
  150. void         USBGetAddress(UInt32 *count, UInt8 *buf);
  151. void         USBSetisr(ProcPtr isr, void *cookie);
  152. OSStatus     USBSetAddress(UInt32 count, UInt8 *buf);
  153. OSStatus     USBSetMulticastFilters(UInt32 numFilters, EnetAddressListPtr list);
  154. OSStatus     USBSetPacketFilter(UInt16 *filter);
  155. Boolean     TimeoutPrevRequest(void);
  156. Boolean     TimeoutStallRequest(void);
  157. Boolean     TimeoutDelayRequest(void);
  158. OSStatus     USBEnetDriverEntry(USBDeviceRef device, USBDeviceDescriptor *desc);
  159. static void InitializePB(USBPB *pb, USBDeviceRef ref, USBCompletion handler);
  160. void         readCompletion(USBPB *pb);
  161. void         USBStartupRead(void);
  162. void         USBStartReadPolling(UInt32 bufindx);
  163. void         USBStopReadPolling(void);
  164. void         writeCompletion(USBPB *pb);
  165. OSStatus     USBEnetWrite(UInt32 count, UInt8 *buf);
  166. void         KillUSBIO(void);
  167. void         DoDelay(void);
  168. static void delayHandler(USBPB *pb);
  169. void         ClearDevice(void);
  170. static void stallHandler(USBPB *pb);
  171. UInt8         Asciify(UInt8 i);
  172.  
  173. #if ((DebugOn > 0) && (LogOn > 0))
  174. void         USBLogData(UInt8 Dir, UInt32 Count, UInt8 *buf);
  175. #endif
  176.  
  177. #endif
  178.